
$("#myform").submit(function(event){
    event.preventDefault();

    const formData = $(this).serialize();
    $.ajax({
        url: "/user/login",
        data: formData,
        method : "POST",
        dataType: "json",
        success : function(data) {
            if(data.code === 1 ){
                alert('登录成功！');
                window.location.href = "/";
            }
            else{
                if (data.email){
                    $("#error_email").text(data.email);
                }
                else if (data.password){
                    $("#error_password").text(data.password);
                }
                else{
                    $("#error_vcode").text(data.code);
                }
            }
        }

    })
})

$(".onlogin").click(function(){
var timestamp = new Date().getTime();
    $(".onlogin").attr("src","/user/vcode?a=" + timestamp);
})
